﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/AdminTemplate.Master" AutoEventWireup="true" CodeBehind="ManageNews.aspx.cs" Inherits="RealtorsPortal.AdminCP.ManageNews" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>News Management</title>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            //set option
            $("#navheadAdmin").addClass("selected");
            $("#mnuAdmin").css("display", "block");
            $(".submenu li a[title='Manage news']").css({ "color": "#fff", "background": "#222", "border": "1px solid #333" });

            $("#contentArea").tabs(); //tab view
        });



        ///confirm add category
        function confirm() {
            var answer = confirm("Are you sure?");
            return answer;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>
        NEWS MANAGEMENT</h1>
    <div id="contentArea">
        <ul>
            <li><a href="#tab1">List all news</a></li>
            <li><a href="#tab2">Add new News</a></li>
        </ul>
        <div id="tab1">
            <h2>
                News</h2>
            <asp:GridView ID="grdNewsList" runat="server" AutoGenerateColumns="False" onrowcommand="grdNewsList_RowCommand" 
                DataKeyNames="NewsId" onpageindexchanging="grdNewsList_PageIndexChanging" 
                onrowcancelingedit="grdNewsList_RowCancelingEdit" 
                onrowediting="grdNewsList_RowEditing" Height="138px" Width="100%"
            >
                <HeaderStyle CssClass="header_gridview" />
                <Columns>
                    <asp:CheckBoxField />
                    <asp:TemplateField HeaderText="ID">
                        <ItemTemplate>
                            <%# Eval("NewsId")%>
                        </ItemTemplate>
                        <HeaderStyle Width="15px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Writer id">
                        <ItemTemplate>
                            <%# Eval("AdminId")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <%# Eval("AdminId")%>
                        </EditItemTemplate>
                        <HeaderStyle Width="25px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Title">
                        <ItemTemplate>
                            <%# Eval("Title")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("Title") %>' Visible="true"></asp:TextBox>
                        </EditItemTemplate>
                        <HeaderStyle Width="100px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Content"  ItemStyle-HorizontalAlign="Justify" ItemStyle-VerticalAlign="Middle">
                        <ItemTemplate>
                            <%#Eval("Content")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtContent" runat="server" text = '<%#Bind("Content")%>' Enabled="true" TextMode="MultiLine" />
                        </EditItemTemplate>
                        <HeaderStyle VerticalAlign="Top" Width="210px" />

<ItemStyle HorizontalAlign="Justify" VerticalAlign="Middle"></ItemStyle>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Image">
                        <ItemTemplate>
                            <asp:Label ID="lblNewsImage" runat="server" Text='<%#Eval("NewsImage")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:FileUpload ID="fuImage" runat="server" />
                        </EditItemTemplate>
                    </asp:TemplateField>


                    <asp:TemplateField HeaderText="Date">
                        <ItemTemplate>
                            <%#Eval("WritedDate")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtDate" runat="server" text = '<%#Bind("WritedDate")%>' Enabled="true" TextMode="MultiLine" />
                            <asp:RangeValidator ID="RngAge" ValidationGroup="FormVal" runat="server" ControlToValidate="txtDate" Display="Dynamic" ErrorMessage='Date format error, try "dd/MM/yyyy"' MinimumValue="1/1/1900" MaximumValue = "12/31/2099" Type="Date">*</asp:RangeValidator>
                        </EditItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Actions" ItemStyle-HorizontalAlign="Justify" ItemStyle-VerticalAlign="Middle">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' >
                                <asp:Image ID="ibtnEdit" runat="server" ImageUrl="assets/b_edit.png"/>
                                </asp:LinkButton>
                            <asp:LinkButton ID="LinkButton2" runat="server" CommandName="DeleteCommand"
                                CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' >
                                <asp:Image ID="ibtnDelete" runat="server" ImageUrl="assets/b_drop.png" />
                                </asp:LinkButton>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:LinkButton ID="lbtnUpdate" runat="server" ValidationGroup="update" CausesValidation="True"
                                CommandName="UpdateCommand" Text="Update" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'></asp:LinkButton>
                            <asp:LinkButton ID="lbtnCancel" runat="server" ValidationGroup="update" CausesValidation="True"
                                CommandName="Cancel" Text="Cancel" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'></asp:LinkButton>
                        </EditItemTemplate>

<ItemStyle HorizontalAlign="Justify" VerticalAlign="Middle"></ItemStyle>
                    </asp:TemplateField>
                </Columns>
                <PagerStyle CssClass="pager_gridview" Width="50px" />
            </asp:GridView>
            <asp:Label ID="Label1" runat="server" Text="Display: "></asp:Label><asp:DropDownList
                ID="ddlPageSize" runat="server" AutoPostBack="True" 
                onselectedindexchanged="ddlPageSize_SelectedIndexChanged">
                <asp:ListItem>5</asp:ListItem>
                <asp:ListItem>10</asp:ListItem>
                <asp:ListItem>20</asp:ListItem>
            </asp:DropDownList>
        </div>
        <div id="tab2">
            <h2>Add a News</h2>
            <fieldset>
            <legend>News Detail</legend>
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
                    ValidationGroup="add" Font-Bold="True" ForeColor="Red" />
            <div class="input_field">
                <label>
                    Title(*):
                </label>
                <asp:TextBox ID="txtTitle" runat="server" Width="215px" required="true">
                </asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txtTitle" ErrorMessage="Category Name is required" Font-Bold="True" 
                    ForeColor="Red" Text="*" ValidationGroup="add"></asp:RequiredFieldValidator>
            </div>

            <div class="input_field">
                <label>
                    Content(*):
                </label>
                <asp:TextBox ID="txtContent" runat="server" required="true" TextMode="MultiLine" Width="300px" Height="150px">
                </asp:TextBox>

                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ErrorMessage="Content is required" Font-Bold="True" 
                    ForeColor="Red" ControlToValidate="txtContent" Text="*" ValidationGroup="add"></asp:RequiredFieldValidator>
            </div>

            <div class="input_field">
                <label>
                    Images(*):
                </label>
                <asp:FileUpload ID="fuNewsImage" runat="server" />
            </div>

            <div class="input_field no_margin_bottom">
                <asp:Label ID="lblStatus" runat="server" ForeColor="Red"></asp:Label>
            <asp:Button ID="btnAdd" runat="server" Text="ADD" CssClass="submit" 
                    ValidationGroup="add" OnClientClick="return confirm();" onclick="btnAdd_Click" />
            <input class="submit" type="reset" value="RESET" />
            
        </div>
        </fieldset>
        </div>
    </div>
</asp:Content>
